#ifndef ENGINE_GL_GLUT_H
#define ENGINE_GL_GLUT_H

#include "lib/cgeServerSocket.h"
#include "lib/cgeDatagramPacket.h"
#include "lib/cgeDatagramSocket.h"

using namespace basterd;
using namespace basterd::util;
using namespace basterd::net;

#include "Engine.h"
#include <GL/glut.h>
#include <map>

class EngineParameters;

/// Engine do GLUT
class Engine
{
public:
    Engine(void);
    ~Engine(void);

    bool init( const EngineParameters& params );
    void shutdown(void);
    void loop(void);
    void drawScene(void);
    void drawQuad(void);
    Object& addObject(void);

    static int loadTexture( const char* filename );


protected:

    static void keyboardFunc( unsigned char key, int x, int y );
    static void reshapeFunc( int w, int h );
    static void displayFunc(void);
    static void idleFunc(void);

    void resizeWindow( unsigned int width, unsigned int height );
    void setKeyState( int keyCode, bool state );
    bool getKeyState( int keyCode );


    bool running;
    bool server;
    unsigned int width;
    unsigned int height;
    int screen;
    ILuint imageID;
    typedef std::map<int,bool> KeyCodeMap;
    KeyCodeMap keyMap;


    std::vector<Object> objetos;

    DatagramSocket socket;
    DatagramPacket packet;

};

#endif // ENGINE_GL_GLUT_H
